import Vue from 'vue'
import Router from 'vue-router'

const home = r => require.ensure([], () => r(require('../basic/home/index')), 'home')
const homePage = r => require.ensure([], () => r(require('../components/homepage/index')), 'home')
const allCourse = r => require.ensure([], () => r(require('../components/course/allCourse')), 'course')
const resultCourse = r => require.ensure([], () => r(require('../components/course/resultCourse')), 'course')
const pullCourse = r => require.ensure([], () => r(require('../components/course/pullCourse')), 'course')
const categoryCourse = r => require.ensure([], () => r(require('../components/course/categoryCourse')), 'course')
const directionCourse = r => require.ensure([], () => r(require('../components/course/directionCourse')), 'course')
const courseDetail = r => require.ensure([], () => r(require('../components/course/courseDetail')), 'course')
const payPage = r => require.ensure([], () => r(require('../components/payment/payPage')), 'payment')
const payDetails = r => require.ensure([], () => r(require('../components/payment/payDetails')), 'payment')
const paySuccee = r => require.ensure([], () => r(require('../components/payment/paySuccee')), 'payment')
const wechatPage = r => require.ensure([], () => r(require('../components/payment/wechatPage')), 'home')
const alipayPage = r => require.ensure([], () => r(require('../components/payment/alipayPage')), 'home')
const ywtpayPage = r => require.ensure([], () => r(require('../components/payment/ywtpayPage')), 'home')
const orderDetails = r => require.ensure([], () => r(require('../components/personal/orderDetalis')), 'personal')
const personal = r => require.ensure([], () => r(require('../components/personal/personal')), 'personal')
const emailCheckPage = r => require.ensure([], () => r(require('../components/personal/emailCheckPage')), 'emailCheckPage')
const contract = r => require.ensure([], () => r(require('../basic/start/gokContract')), 'home')
const error1 = r => require.ensure([], () => r(require('../basic/error/error404')), 'home')
const error2 = r => require.ensure([], () => r(require('../basic/error/error500')), 'home')
const meRedact = r => require.ensure([], () => r(require('../components/personal/meRedact')), 'meRedact')
const classMien = r => require.ensure([], () => r(require('../components/course/classMien')), 'classMien')
const classMienDetail = r => require.ensure([], () => r(require('../components/course/classMienDetail')), 'classMienDetail')
const classPlan = r => require.ensure([], () => r(require('../components/classPlan/classH5')), 'classPlan')
// const H5Login = r => require.ensure([], () => r(require('../components/classPlan/login')), 'H5Login')
// const H5ClassList = r => require.ensure([], () => r(require('../components/classPlan/classList')), 'H5ClassList')
const WebClassList = r => require.ensure([], () => r(require('../components/classPlan/webClassList')), 'webClassList')
const WebSlectData = r => require.ensure([], () => r(require('../components/classPlan/WebSlectData')), 'WebSlectData')
// const H5SelectData = r => require.ensure([], () => r(require('../components/classPlan/selectDate')), 'H5SlectData')

// const H5FastSelect = r => require.ensure([], () => r(require('../components/classPlan/fastSelect')), 'H5FastSelect')
const webFastSelect = r => require.ensure([], () => r(require('../components/classPlan/webFastSlect')), 'webFastSlect')
const webSubmitSuccess = r => require.ensure([], () => r(require('../components/classPlan/webSubmitSuccess')), 'webSubmitSuccess')
// const H5SubmitSuccess = r => require.ensure([], () => r(require('../components/classPlan/submitSuccess')), 'H5SubmitSuccess')

const checkendCertificate = r => require.ensure([], () => r(require('../components/personal/checkendCertificate')), 'personal')
const uploadJobmes = r => require.ensure([], () => r(require('../components/personal/uploadJobmes')), 'personal')
const H5process = r => require.ensure([], () => r(require('../components/process/process')), 'H5process')
const allNews = r => require.ensure([], () => r(require('../components/news/allNews')), 'allNews')
// const testVideo = r => require.ensure([], () => r(require('../components/testVideo')), 'testVideo')
Vue.use(Router)
const REG = /Android|webOS|iPhone|iPod|BlackBerry/i
let basicURL = navigator.userAgent
let isPhone = REG.test(basicURL);


let routes = [
  {
    path: '/home',
    redirect: '/'
  },
  {
    name: 'home',
    path: '/',
    component: home,
    children: [
    {
      path: '/',
      component: homePage,
      meta: {
        keepAlive: false
      }
    },
    // {
    //   path: '/testVideo',
    //   component: testVideo,
    //   meta: {
    //     keepAlive: false
    //   }
    // }, 
    {
      name: 'allCourse',
      path: '/allCourse',
      component: allCourse,
      meta: {
        keepAlive: false
      }
    },
    {
      path: '/classMien',
      component: classMien,
      name: 'classMien',
      meta: {
        keepAlive: false
      }
    },
    {
      path: '/classMienDetail',
      component: classMienDetail,
      name: 'classMienDetail',
      meta: {
        keepAlive: false
      }
    },
    {
      path: '/resultCourse',
      component: resultCourse,
      meta: {
        keepAlive: false
      }
    },
    {
      path: '/pullCourse',
      component: pullCourse,
      meta: {
        keepAlive: false
      }
    },
      {
        path: '/contract',
        component: contract,
        meta: {
          keepAlive: false
        }
      },
      {
        path: '/categoryCourse',
        component: categoryCourse,
        meta: {
          keepAlive: false
        }
      },
      {
        path: '/directionCourse',
        component: directionCourse,
        meta: {
          keepAlive: false
        }
      },
      {
        path: '/payPage', // 支付页面
        name: 'payPage',
        component: payPage,
        meta: {
          keepAlive: false
        }
      },
      {
        path: '/payDetails',
        name: 'payDetails',
        component: payDetails,
        meta: {
          keepAlive: false
        }
      },
      {
        path: '/paySuccee',
        name: 'paySuccee',
        component: paySuccee,
        meta: {
          keepAlive: false
        }
      },
      {
        path: '/orderDetails', // 查看分期
        name: 'orderDetails',
        component: orderDetails,
        meta: {
          keepAlive: false
        }
      },
      {
        path: '/checkendCertificate', // 查看结课证书
        name: 'checkendCertificate',
        component: checkendCertificate,
        meta: {
        keepAlive: false
        }
        },
      {
        path: '/uploadJobmes', // 提交材料
        name: 'uploadJobmes',
        component: uploadJobmes,
        meta: {
        keepAlive: false
        }
        },
      {
        path: '/alipayPage', // 支付宝支付页面
        name: 'alipayPage',
        component: alipayPage,
        meta: {
        keepAlive: false
        }
        },
      {
        path: '/wechatPage', // 微信支付页面
        name: 'wechatPage',
        component: wechatPage,
        meta: {
          keepAlive: false
        }
      },
      {
        path: '/ywtpayPage', // 一网通支付页面
        name: 'ywtpayPage',
        component: ywtpayPage,
        meta: {
        keepAlive: false
        }
        },
      {
        path: '/courseDetail',
        name: 'courseDetail',
        component: courseDetail,
        meta: {
          keepAlive: false
        }
      },
      {
        path: '/personal', //个人中心
        component: personal,
        meta: {
          keepAlive: false
        }
      },
      {
        path: '/emailCheckPage', //邮箱验证页面
        component: emailCheckPage,
        meta: {
          keepAlive: false
        }
      },
      {
        path: '/meRedact', //我的资料编辑页面
        component: meRedact,
        meta: {
          keepAlive: false
        }
      },
      {
        name: 'classPlan',
        path: '/classList',
        component: WebClassList,
        meta: {
          keepAlive: false
        }
      },
      {
        name: 'classPlan',
        path: '/slectData',
        component: WebSlectData,
        meta: {
          keepAlive: false
        }
      },
      {
        name: 'classPlan',
        path: '/fastSlect',
        component: webFastSelect,
        meta: {
          keepAlive: false
        }
      },
      {
        name: 'classPlan',
        path: '/webSubmitSuccess',
        component: webSubmitSuccess,
        meta: {
          keepAlive: false
        }
      },
      // {
      //   name: 'H5Login',
      //   path: '/H5Login',
      //   component: H5Login,
      //   meta: {
      //     keepAlive: false,
      //     isPhone: isPhone
      //   }
      // },
      // {
      //   name: 'H5classList',
      //   path: '/H5classList',
      //   component: H5ClassList,
      //   meta: {
      //     keepAlive: false,
      //     isPhone: isPhone
      //   }
      // },
      // {
      //   name: 'H5selectDate',
      //   path: '/H5selectDate',
      //   component: H5SelectData,
      //   meta: {
      //     keepAlive: false,
      //     isPhone: isPhone
      //   }
      // },
      // {
      //   name: 'H5fastSelect',
      //   path: '/H5fastSelect',
      //   component: H5FastSelect,
      //   meta: {
      //     keepAlive: false,
      //     isPhone: isPhone
      //   }
      // },
      // {
      //   name: 'H5submitSuccess',
      //   path: '/H5submitSuccess',
      //   component: H5SubmitSuccess,
      //   meta: {
      //     keepAlive: false,
      //     isPhone: isPhone
      //   }
      // },
      {
        name: 'H5process',
        path: '/H5process',
        component: H5process,
        meta: {
          keepAlive: false,
          isPhone: isPhone
        }
      },
      {
        name: 'allNews',
        path: '/allNews',
        component: allNews,
        meta: {
          keepAlive: false
        }
      },
      {
        path: '*',
        component: error1
      }
    ]
  }
]

export default new Router({
  routes: routes,
  mode: 'history',
  scrollBehavior (to, from, savedPosition) {
    return { x: 0, y: 0 }
  }
})
